import 'package:flutter/material.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';

class CabinetListInfoContent extends StatelessWidget {
  /// 是否可编辑
  final bool isEdit;

  /// 编号
  final String? number;

  /// 指定快递员
  final String? appoint;

  /// 状态
  final String? status;

  /// 编辑事件
  final Function()? editAction;

  const CabinetListInfoContent({
    super.key,
    this.isEdit = true,
    this.number,
    this.appoint,
    this.status,
    this.editAction,
  });

  @override
  Widget build(BuildContext context) {
    return Flex(
      direction: Axis.horizontal,
      children: [
        customWidget(
          child: Text(
            number ?? "",
            textAlign: TextAlign.center,
            style: TextStyle(color: MGColors.text1Color, fontSize: MGFont.textFont2),
          ),
        ),
        customWidget(
          flex: 3,
          child: Text(
            appoint ?? "",
            textAlign: TextAlign.center,
            style: TextStyle(color: isEdit ? MGColors.text1Color : MGColors.text3Color, fontSize: MGFont.textFont2),
          ),
        ),
        customWidget(
          flex: 2,
          child: Text(
            status ?? "",
            textAlign: TextAlign.center,
            style: TextStyle(color: MGColors.text3Color, fontSize: MGFont.textFont2),
          ),
        ),
        customWidget(
          child: InkWell(
            child: Text(
              "编辑",
              textAlign: TextAlign.center,
              style: TextStyle(
                color: isEdit ? MGColors.blueColor : MGColors.text3Color,
                fontSize: MGFont.textFont2,
                decoration: isEdit ? TextDecoration.underline : TextDecoration.none,
                decorationColor: MGColors.blueColor,
              ),
            ),
            onTap: () {
              if (!isEdit) {
                return;
              }
              if (editAction != null) {
                editAction!();
              }
            },
          ),
        ),
      ],
    );
  }

  Widget customWidget({required Widget child, int flex = 1}) {
    return Expanded(
      flex: flex,
      child: Container(
        padding: EdgeInsets.only(top: 15, bottom: 15),
        decoration: BoxDecoration(border: Border.all(color: MGColors.splitColor, width: 0.5)),
        child: child,
      ),
    );
  }
}
